<template>
	<base-page class="edit-form base-form" style="width: 100vw" title="课程评价" @back="onCancel">
		<view class="main-box">
			<view class="content-box">
				<u-form ref="mobileApplyInfoRef" :model="formData" label-width="120px" label-align="left"
					:errorType="['border-bottom', 'message']">
					<u-row gutter="0">
						<u-col :span="12">
							<view class="mt-16">
								<view class="u-cell-group" style="padding: 5px">
									<u-row gutter="0">
										<u-col :span="12">
											<span style="font-weight: bold;">课程内容</span>
											<view style="margin-left: 20px;">
												<u-form-item label="主题适宜性" :required="true">
													<u-rate :count="count" v-model="formData.courseScore1"></u-rate>
												</u-form-item>
												<u-form-item label="内容针对性" :required="true">
													<u-rate :count="count" v-model="formData.courseScore2"></u-rate>
												</u-form-item>
												<u-form-item label="启发价值型" :required="true">
													<u-rate :count="count" v-model="formData.courseScore3"></u-rate>
												</u-form-item>
											</view>

											<span style="font-weight: bold;">授课老师</span>
											<view style="margin-left: 20px;">
												<u-form-item label="教学素养" :required="true">
													<u-rate :count="count" v-model="formData.teacherScore1"></u-rate>
												</u-form-item>
												<u-form-item label="现场互动" :required="true">
													<u-rate :count="count" v-model="formData.teacherScore2"></u-rate>
												</u-form-item>
												<u-form-item label="教学效果" :required="true">
													<u-rate :count="count" v-model="formData.teacherScore3"></u-rate>
												</u-form-item>
											</view>

											<span style="font-weight: bold;">综合评价</span>
											<view style="margin-left: 20px;">
												<u-form-item label="综合评分" :required="true">
													<u-rate :count="count" v-model="formData.score"></u-rate>
												</u-form-item>
												<u-form-item label="意见">
													<uni-easyinput type="textarea" v-model="formData.content"
														placeholder="请输入意见与建议(非必填)" />
												</u-form-item>
											</view>
										</u-col>
									</u-row>
								</view>
							</view>
						</u-col>
					</u-row>
				</u-form>
			</view>
		</view>
		<view class="menu-box">
			<u-button :custom-style="{width: '100%'}" style="flex-grow: 1; margin-left: 8px" type="primary"
				size="medium" @click="onAddClick()">
				提交
			</u-button>
		</view>
		<u-modal v-model="show" :content="content" show-cancel-button  @cancel="onCancel()" @confirm="onCancel()" confirm-text="返回"></u-modal>

	</base-page>
</template>

<script>
	import {
		showMessage,
	} from '@/utils';
	import {
		CourseInfoController,
	} from '@/api';
	import projectConfig from '@/core/config'
	export default {
		name: 'mobileApplyInfo',

		data() {
			return {
				show: false,
				content: '',
				count: 5,
				formData: {
					// id
					id: undefined,
					// 班级id
					classId: undefined,
					// 姓名
					name: undefined,

					officerId: undefined,
					score: 5,
					courseScore1: 5,
					courseScore2: 5,
					courseScore3: 5,
					teacherScore1: 5,
					teacherScore2: 5,
					teacherScore3: 5,
					content: '',

				},
				classIdWidget: [],
				ganbuWidget: [],
				rules: {
					

				},
				fileList: []

			}
		},
		computed() {},
		onLoad(data) {
			if (data.data) {
				this.ganbuWidget = JSON.parse(decodeURIComponent(data.data))
			}
		},
		methods: {
			onCancel() {
				uni.navigateBack();
			},

			changeGan(val, val2) {
				this.formData.officerId = val2.id
				this.formData.jobTitle = val2.jobTitle
				this.formData.name = val2.name
				this.formData.phone = val2.phone
			},
			/**
			 * 提交
			 */
			onAddClick() {
				this.$refs.mobileApplyInfoRef.validate((valid) => {

					let params = {
						courseEvaluateDto: {
							teacherId: this.ganbuWidget.teacherId,
							classId: this.ganbuWidget.classId,
							courseId: this.ganbuWidget.id,
							score: this.formData.score,
							courseScore1: this.formData.courseScore1,
							courseScore2: this.formData.courseScore2,
							courseScore3: this.formData.courseScore3,
							teacherScore1: this.formData.teacherScore1,
							teacherScore2: this.formData.teacherScore2,
							teacherScore3: this.formData.teacherScore3,
							content: this.formData.content,
						}
					};

					CourseInfoController.courseEvaluateAdd(this, params)
						.then((res) => {
							this.show = true;
							if (res) {
								this.content="评价成功"
							}else{
								this.content="评价失败"
							}
							// if (res) {
							// 	this.$u.toast('提交成功');
							// 	uni.navigateTo({
							// 		url: "/views/generated/mobileStudentmyCourse"
							// 	})
							// } else {
							// 	this.$u.toast('提交失败');
							// }

						})
						.catch((e) => {});
				});
			},

		},
		computed: {

		},
		mounted() {}
	};
</script>

<style scoped></style>